package com.source.multithread.run;

public class TestYield2
{
	
	public static void main(String[] args)
	{
		Train2 train=new Train2();
		Thread k386 =new Thread(train,"k386");
		Thread T1=new Thread(train,"T1");
		
		k386.start();
		try
		{
			Thread.sleep(5000);
			k386.yield();
			T1.start();
		} catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		
	}
}
 
class Train2 implements Runnable
{
	public boolean isRun=true;
	@Override
	public void run()
	{
		try
		{
			while(isRun)
			{
				System.out.println(Thread.currentThread().getName()+" 在运行");
				Thread.sleep(1000);
			}
		} catch (Exception e)
		{
			e.printStackTrace();
		}
		
	}
	
}
